//
//  LH24HoursCell.m
//  Project_B
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 ZY. All rights reserved.
//

#import "LH24HoursCell.h"

@implementation LH24HoursCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
#pragma mark- 重写方法
- (void)createViews
{
    // 图片
    _imageV = [UIImageView new];
    [self.contentView addSubview:_imageV];
    [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(@10);
        make.size.mas_equalTo(CGSizeMake(100, 90));
    }];
    
    
    // 标题
    _titleL = [UILabel new];
    [self.contentView addSubview:_titleL];
    self.titleL.font = [UIFont systemFontOfSize:18*ADAPT_FONT];
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_imageV.mas_right).offset(10);
        make.top.equalTo(_imageV);
        make.size.mas_equalTo(CGSizeMake(SCREEN_HEIGHT/7*6-20, 30));
        
    }];
    
    // 详情
    _digestL = [UILabel new];
    _digestL.font = [UIFont systemFontOfSize:16*ADAPT_FONT];
    _digestL.numberOfLines = 0;
    [self.contentView addSubview:self.digestL];
    [_digestL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleL);
        make.top.equalTo(_titleL.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(375-110-10, 40));
        
    }];
    
    // 跟贴
//    self.replyL = [[UILabel alloc] initWithFrame:CGRectMake(self.digestL.frame.origin.x + self.digestL.frame.size.width - 70 * KPropotionWidth, (100 - 15) * KPropotionHeight, 70 * KPropotionWidth, 10)];
    _replyL = [UILabel new];
    _replyL.font = [UIFont systemFontOfSize:14*ADAPT_FONT];
    _replyL.textColor = [UIColor grayColor];
    _replyL.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_replyL];
    [_replyL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.offset(-10);
        make.size.mas_equalTo(CGSizeMake(80, 10));
    }];
    
    // 标识
//    self.tagL = [[UILabel alloc] initWithFrame:CGRectMake(self.digestL.frame.origin.x + self.digestL.frame.size.width - 40, self.digestL.frame.origin.y + 30, 30, 15)];
//    self.tagL.layer.allowsEdgeAntialiasing =YES;
//    self.tagL.layer.borderWidth = 0.3;
//    self.tagL.layer.borderColor = [UIColor blueColor].CGColor;
//    self.tagL.textAlignment = NSTextAlignmentCenter;
//    self.tagL.font = [UIFont systemFontOfSize:12.0 * KPropotionFont];
//    self.tagL.textColor = [UIColor blueColor];

    
    // 隔断
//    UILabel *downL = [[UILabel alloc] initWithFrame:CGRectMake(0, 100 * KPropotionHeight - 2, SCREEN_FRAME.size.width, 2)];
    UILabel *downL = [UILabel new];
    downL.backgroundColor = [UIColor colorWithWhite:0.703 alpha:1.000];
    [self.contentView addSubview:downL];
    [downL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.bottom.equalTo(@0);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 2));
        
    }];
}

- (void)setModel:(LH24HoursModel *)model
{
    //图片
    [_imageV sd_setImageWithURL:[NSURL URLWithString:model.imgsrc] placeholderImage:PLACEHOLDER_IMAGE];
    
    // 标题
    _titleL.text = model.title;
    
    // 简介
    _digestL.text = model.digest;
    
    // 判断跟贴
    if (nil != [NSString stringWithFormat:@"%@", model.replyCount]) {
        
        self.replyL.text = [NSString stringWithFormat:@"%@跟帖", model.replyCount];
        
    } else {
        
        self.replyL.text = @"专题";
        
    }

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
